#!/usr/bin/ruby
# -*- ruby -*-
#
# http://programmingpraxis.com/2012/10/30/pandigital-numbers/

require 'set'

match = Set.new("0123456789".split(//))

pandigitals = Set.new

(100 .. 999).each do |a|
    (100 .. 999).each do |b|
        pandigitals << [a, b] if match == Set.new((a.to_s + b.to_s + (a + b).to_s).split(//))
    end
end

pandigitals.to_a.sort { |a, b| a.first <=> b.first }.each do |(a, b)|
    puts "#{a} + #{b} = #{a + b}"
end
